package wine.ejb.utilities;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;


/**
 * @author chg E-mail:chg85031@163.com
 * @version createDate：2008-11-27 下午03:40:47
 * @describe 公用方法类
 */
public class Utility {

	/**
	 * @return 返回当前日期的一种格式
	 */
	public static String getCurrentDate() {
		String d = "";
		Calendar c = Calendar.getInstance();
		int year = c.get(1);
		int month = c.get(2) + 1;
		int date = c.get(5);
		d = year + "年" + month + "月" + date + "日";
		return d;
	}
	/**
	 * yyyy-MM-dd
	 * @return 返回当前日期的一种格式
	 */
	public static String getCurrentDate(Date dateTime) {
		String d = null;
		if(dateTime!=null){
			Calendar c = Calendar.getInstance();
			c.setTime(dateTime);
			int year = c.get(Calendar.YEAR);
			int month = c.get(Calendar.MONTH) + 1;
			int date = c.get(Calendar.DATE);
			d = year + "-" + month + "-" + date;
		}
		return d;
	}
	public static java.util.Date today() {
		Calendar c = Calendar.getInstance();
		return c.getTime();
	}

	public static java.util.Date addDay(Integer amount) {
		return addDay(null, amount);
	}

	public static java.util.Date addDay(java.util.Date date, Integer amount) {
		Calendar c = Calendar.getInstance();
		if (date != null) {
			c.setTime(date);
		}
		c.add(Calendar.DAY_OF_MONTH, amount);
		return c.getTime();
	}

	/**
	 * 获取类型为java.util.date格式的日期
	 * 
	 * @return
	 */
	public static Date getCurrentDateForSql() {
		Calendar c = Calendar.getInstance();
		Date d = new Date(c.getTimeInMillis());
		return d;
	}

	/**
	 * 通过String类型的时间转换为java.util.date格式的时间
	 * 
	 * @param dateTime
	 *            时间
	 * @return
	 */
	public static Date getDateFString(String dateTime) {
		
		DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
		java.util.Date date = null;
		try {
			if ("".equals(dateTime)) {
				return null;
			}
			date = fmt.parse(dateTime);
		} catch (Exception ex) {
			Log.error(dateTime);
			Log.error(ex.getMessage());
			ex.printStackTrace();
		}
		return new Date(date.getTime());
	}
	/**
	 * 把传入的时间转换为yyyy-MM-dd的格式 
	 * @param dateTime 如果为null返回则为""
	 * @return 返回yyyy-MM-dd格式的时间
	 */
	public static String getFormatDate(Date dateTime) {
		String date = "";
		try{
			DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
			date=fmt.format(dateTime);
		}catch(Exception e){
			return "";
		}
		if(date==null){
			date="";
		}
		return date;
	}

	/**
	 * 通过String类型的时间转换为java.util.date格式的时间
	 * 
	 * @param dateTime
	 *            时间
	 * @return
	 */
	public static Date getDateFStrings(String dateTime) {

		DateFormat fmt = null;
		java.util.Date date = null;
		if (dateTime == null || "".equals(dateTime)) {
			return null;
		}
		try {
			fmt = new SimpleDateFormat("yyyy-MM-dd");
			date = fmt.parse(dateTime);
		} catch (Exception ex) {
			Log.error(dateTime);
			Log.error(ex.getMessage());
			try {
				fmt = new SimpleDateFormat("yyyy.MM.dd");
				date = fmt.parse(dateTime);
			} catch (Exception ex2) {
				Log.error(dateTime);
				Log.error(ex2.getMessage());
				try {
					fmt = new SimpleDateFormat("yyyy.MM");
					date = fmt.parse(dateTime);
				} catch (Exception ex3) {
					Log.error(dateTime);
					Log.error(ex3.getMessage());
					return null;
				}
			}
		}
		return new Date(date.getTime());
	}

	/**
	 * 通过15位和18位身份证计算出生日期
	 * 
	 * @param CardId
	 * @return
	 */
	public static Date getDateFStringCardId(String CardId) {
		if (CardId == null || "".equals(CardId)) {
			return null;
		}
		DateFormat fmt = new SimpleDateFormat("yyyyMMdd");
		String timeStr = null;
		java.util.Date date = null;
		if (CardId.length() == 15) {
			timeStr = "19";
			timeStr += CardId.substring(6, 12);
			try {
				date = fmt.parse(timeStr);
			} catch (ParseException e) {
				Log.debug(timeStr);
				Log.debug(e.getMessage());
				return null;
			}
		} else if (CardId.length() == 18) {
			timeStr = CardId.substring(6, 14);
			try {
				date = fmt.parse(timeStr);
			} catch (ParseException e) {
				Log.debug(timeStr);
				Log.debug(e.getMessage());
				return null;
			}
		} else {
			return null;
		}
		return new Date(date.getTime());
	}

	/**
	 * 通过15位和18位身份证计算男女(15位号中第15位为性别判定，18位号中第17位为性别判定)(基数为男偶数为女)
	 * 
	 * @param CardId
	 * @return
	 */
	public static String getSexFStringCardId(String CardId) {
		String sex = "男";
		if (CardId == null || "".equals(CardId)) {
			return sex;
		}
		// =IF(MOD(IF(LEN(A1)>15,MID(A1,17,1),MID(A1,15,1)),2),"男","女")
		if (CardId.length() == 15) {
			if ((Integer.parseInt(CardId.substring(14)) % 2) == 0) {
				sex = "女";
			}
		} else if (CardId.length() == 18) {
			if ((Integer.parseInt(CardId.substring(16, 17)) % 2) == 0) {
				sex = "女";
			}
		}
		return sex;
	}

	public static Object copyTo(Object from, Object to) {
		if ((from == null) || (to == null)) {
			return null;
		}
		Field[] fromFields = from.getClass().getDeclaredFields();
		Field[] toFields = to.getClass().getDeclaredFields();
		Method fromMethod;
		Method toMethod;
		String fromMethodName, toMethodName;
		for (Field f : fromFields) {
			if (!"ID".equalsIgnoreCase(f.getName())) {
				fromMethodName = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
				toMethodName = "set" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
				try {

					fromMethod = from.getClass().getMethod(fromMethodName, null);

					toMethod = to.getClass().getMethod(toMethodName, new Class[] { fromMethod.getReturnType() });

					Object v = fromMethod.invoke(from, null);
					toMethod.invoke(to, new Object[] { v });
				} catch (SecurityException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (NoSuchMethodException e) {
					// TODO Auto-generated catch block
					Log.debug(toMethodName + " not found!");
					// e.printStackTrace();
				} catch (IllegalArgumentException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (InvocationTargetException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

		}
		return to;
	}
	/**
	 * 将from的数据copy到to(to现有的数据不被覆盖)
	 * @param from
	 * @param to
	 * @return
	 */
	public static Object copyTo2(Object from, Object to) {
		if(Utility.isNotEmpty(from)&&Utility.isNotEmpty(to)) {
			Field[] fromFields = from.getClass().getDeclaredFields();
			Method fromMethod,toMethod,to2Method;
			String fromMethodName, toMethodName;
			for (Field f : fromFields) {
				if (!"ID".equalsIgnoreCase(f.getName())) {
					fromMethodName = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
					toMethodName = "set" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
					try {
						fromMethod = from.getClass().getMethod(fromMethodName, null);
						to2Method = to.getClass().getMethod(fromMethodName, null);
						
						Object v = fromMethod.invoke(from, null);
						Object v2 = to2Method.invoke(to, null);
						
						if(!Utility.isNotEmptyObj(v2)){
							toMethod = to.getClass().getMethod(toMethodName, new Class[] {fromMethod.getReturnType()});
							toMethod.invoke(to, new Object[] { v });
						}
					} catch (SecurityException e) {
						e.printStackTrace();
					} catch (NoSuchMethodException e) {
						Log.debug(toMethodName + " not found!");
						// e.printStackTrace();
					} catch (IllegalArgumentException e) {
						e.printStackTrace();
					} catch (IllegalAccessException e) {
						e.printStackTrace();
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}
				}
				
			}
		}
		return to;
	}
	/**
	 * 将from有的数据copy到to
	 * @param from
	 * @param to
	 * @return
	 */
	public static Object copyTo3(Object from, Object to) {
		if(Utility.isNotEmpty(from)&&Utility.isNotEmpty(to)) {
			Field[] fromFields = from.getClass().getDeclaredFields();
			Method fromMethod,toMethod,to2Method;
			String fromMethodName, toMethodName;
			for (Field f : fromFields) {
				if (!"ID".equalsIgnoreCase(f.getName())&&!"PK".equalsIgnoreCase(f.getName())) {
					fromMethodName = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
					toMethodName = "set" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
					try {
						fromMethod = from.getClass().getMethod(fromMethodName, null);
						to2Method = to.getClass().getMethod(fromMethodName, null);
						
						Object v = fromMethod.invoke(from, null);
						Object v2 = to2Method.invoke(to, null);
						
						if(Utility.isNotEmptyObj(v)){
							toMethod = to.getClass().getMethod(toMethodName, new Class[] {fromMethod.getReturnType()});
							toMethod.invoke(to, new Object[] { v });
						}
					} catch (SecurityException e) {
						e.printStackTrace();
					} catch (NoSuchMethodException e) {
						Log.debug(toMethodName + " not found!");
						// e.printStackTrace();
					} catch (IllegalArgumentException e) {
						e.printStackTrace();
					} catch (IllegalAccessException e) {
						e.printStackTrace();
					} catch (InvocationTargetException e) {
						e.printStackTrace();
					}
				}
	
			}
		}
		return to;
	}
	/**
	 * 比较的对象类型要一样
	 * 
	 * @param from
	 *            参照对象
	 * @param to
	 *            比较对象
	 * @return false对象不相同,true对象相同
	 */
	public static boolean equalsObj(Object from, Object to) {

		if ((from == null) && (to == null)) {
			return true;
		} else if ((from == null) || (to == null)) {
			return false;
		}
		Field[] fromFields = from.getClass().getDeclaredFields();
		Field[] toFields = to.getClass().getDeclaredFields();
		Method fromMethod;
		Method toMethod;
		String fromMethodName;
		for (Field f : fromFields) {
			fromMethodName = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
			try {

				fromMethod = from.getClass().getMethod(fromMethodName, null);
				toMethod = to.getClass().getMethod(fromMethodName, null);

				Object v = fromMethod.invoke(from, null);
				Object t = toMethod.invoke(to, null);

				if (v != null) {
					// f.getType();
					if (!v.equals(t)) {
						return false;
					}
				} else {
					if (v != t) {
						return false;
					}
				}

			} catch (SecurityException e) {
				e.printStackTrace();
				return false;
			} catch (NoSuchMethodException e) {
				Log.debug(fromMethodName + " not found!");
				e.printStackTrace();
				return false;
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
				return false;
			} catch (IllegalAccessException e) {
				e.printStackTrace();
				return false;
			} catch (InvocationTargetException e) {
				e.printStackTrace();
				return false;
			}
		}
		return true;
	}
	/**
	 * 把一个对象的属性值赋给另一个对象
	 * @param from
	 * @param to
	 * @param fromFields
	 * @param toFields
	 * @return
	 */
	public static Object copyObjectByProperties(Object from,Object to,String[] fromFields,String[] toFields){
		if(from!=null&&to!=null){
			if(fromFields!=null&&toFields!=null&&fromFields.length==toFields.length){
				for(int i=0;i<toFields.length;i++){
					try {
						//BeanUtils.copyProperty(to, toFields[i],getFieldValue(from, fromFields[i]));
						setObjectProperty(to, toFields[i], getFieldValue(from, fromFields[i]));
					} catch (SecurityException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IllegalArgumentException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (NoSuchFieldException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (NoSuchMethodException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}catch (IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					} catch (InvocationTargetException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		}
		return to;
	}
	/**
	 * 判定两个对象指定的属性值是否相等
	 * @param one
	 * @param sec
	 * @param fields
	 * @return
	 */
	public static boolean isEqualsByPoperties(Object one,Object sec,String[] fields){
		if(one==null&&sec==null){
			return true;
		}else if(one==null||sec==null){
			return Boolean.FALSE;
		}
		if(fields==null||fields.length==0){
			return equalsObj(one,sec);
		}
		for(String fieldsName:fields){
			 if(!equals(getFieldValue(one,fieldsName), getFieldValue(sec,fieldsName))){
				return Boolean.FALSE;
			}
		}
		return true;
	}
	/**
	 * 判定两个对象指定的属性值是否相等
	 * @param one
	 * @param sec
	 * @param fields
	 * @return
	 */
	public static boolean isEqualsByPoperties(Object one,Object sec,String[] oneFields,String[] secFields){
		if(one==null&&sec==null){
			return true;
		}else if(one==null||sec==null){
			return Boolean.FALSE;
		}
		if(oneFields!=null&&secFields!=null&&oneFields.length==secFields.length&&oneFields.length>0){
			for(int i=0;i<oneFields.length;i++){
				if(!equals(getFieldValue(one,oneFields[i]), getFieldValue(sec,secFields[i]))){
					return Boolean.FALSE;
				}
			}
			
		}
		return true;
	}
    public static boolean equals(Object object1, Object object2) {    
	        if (object1 == object2) {    
	            return true;    
  	        }    
	        if ((object1 == null) || (object2 == null)) {    
	            return false;    
  	        }    
	        return object1.equals(object2);    
	}
    /**
     * 
     * @author Jan 17, 2013 xiaofei0620@gmail.com
     * @param o
     * @return
     */
	public static boolean isAllPropertiesNotEmpty(Object o){
		if(o==null){
			return false;
		}
		Field[] fs =o.getClass().getDeclaredFields();
		for(Field f:fs){
			if(!isNotEmpty(getFieldValue(o, f.getName()))){
				return false;
			}
		}
		return true;
	}
	/**
	 * 
	 * @author Jan 17, 2013 xiaofei0620@gmail.com
	 * @param o
	 * @param properties
	 * @return
	 */
	public static boolean isAllPropertiesNotEmpty(Object o,String[]  properties){
		if(o==null){
			return false;
		}
		if(properties==null||properties.length<1){
			return isAllPropertiesNotEmpty(o);
		}
		for(String name:properties){
			if(!isNotEmpty(getFieldValue(o, name))){
				return false;
			}
		}
		return true;
	}
	public static String getTableName(Class c) {
		return null;
	}

	/**
	 * 验证传来的参数 is Not null and is not ""
	 * 
	 * @param str
	 *            字符参数
	 * @return
	 */
	public static String validateStrNotNullNotTirm(String str) {
		if (str != null && !"".equals((str = str.trim()))) {
			return str;
		}
		return null;
	}

	/**
	 * 指定长度len的字符串型数字str加步长step
	 * 
	 * @param str
	 * @param len
	 * @param step
	 * @return
	 */
	public static String incStrint(String str, int len, int step) {
		StringBuffer newNoStr = new StringBuffer("1");
		for (int i = len; i > 1; i--) {
			newNoStr.insert(0, "0");
		}
		if (str != null) {
			try {
				Integer no = new Integer(str);
				StringBuffer newNo = new StringBuffer((no + 1) + "");
				int nlen = newNo.length();
				for (int i = len; i > nlen; i--) {
					newNo.insert(0, "0");
				}
				newNoStr = newNo;
			} catch (Exception e) {
				Log.error("--------字符串内容应为数字！");
			}
		}
		return newNoStr.toString();
	}

	public static Object getFieldValue(Object o, String fieldName) {
		try {
			Field f = o.getClass().getDeclaredField(fieldName);
			if (f != null) {
				String getMethodName = "get" + f.getName().substring(0, 1).toUpperCase() + f.getName().substring(1);
				Method method = o.getClass().getMethod(getMethodName, null);
				return method.invoke(o, null);
			}
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}
	public static Object setObjectProperty(Object dest,String fieldName,Object value) throws SecurityException, NoSuchFieldException
	, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
		// TODO Auto-generated method stub
		Field field;
		Method method;
		String getMethodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
		String setMethodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
		field = dest.getClass().getDeclaredField(fieldName);
		if (field != null) {
			method = dest.getClass().getMethod(getMethodName, null);
			Class c = method.getReturnType();
			method = dest.getClass().getMethod(setMethodName, c);
			method.invoke(dest, value);
		}
		return dest;
	}
	/**
	 * @throws SecurityException
	 * @throws NoSuchFieldException
	 * @throws NoSuchMethodException
	 * @throws InvocationTargetException
	 */
	public static Object generateDefaultValue(Object obj, String fieldName, Object defaultValue) throws SecurityException, NoSuchFieldException,
			NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
		Field field;
		Method method;
		String getMethodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
		String setMethodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
		field = obj.getClass().getDeclaredField(fieldName);
		if (field != null) {
			method = obj.getClass().getMethod(getMethodName, null);
			Class c = method.getReturnType();
			Object value = method.invoke(obj, null);
			if (value == null) {
				method = obj.getClass().getMethod(setMethodName, c);
				method.invoke(obj, defaultValue);
			}
		}
		return obj;
	}
	

	public static Long GetDiff(Date d1) throws ParseException{
		  SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		  java.util.Date now = df.parse(df.format(new Date()));
		   java.util.Date date=df.parse(d1.toString());
		   Long l=now.getTime()-date.getTime();
		   Long hour=(l/(60*60*1000));
		   return hour;
	}
	
	/**
	 * 判断str是有效字符串并且!"".equals(str.trim())
	 * @param str
	 * @return 有效返回true无效返回false
	 */
	public static boolean isNotEmpty(String str){
		if(str!=null&&!"".equals(str.trim())){
			return true;
		}else{
			return false;
		}
	}
	public static String formateMessage(String strInit,Object... obj){
		return MessageFormat.format(strInit, obj);
	}
	public static boolean isNotEmpty(Long log){
		if(log!=null&&log>0L){
			return true;
		}else{
			return false;
		}
	}
	
	public static boolean isNotEmpty(long log){
		if(log>0L){
			return true;
		}
		return false;
	}
	/**
	 * 判断id是否有效，id!=null&&id>0
	 * @param id
	 * @return
	 */
	public static boolean isNotEmpty(Integer id){
		if(id!=null&&id>0){
			return true;
		}else{
			return false;
		}
	}
	/**
	 * 判断id是否有效，id!=null&&id>0
	 * @param id
	 * @return
	 */
	public static boolean isNotEmpty(Integer[] ids){
		if(ids!=null&&ids.length>0){
			return true;
		}else{
			return false;
		}
	}
	/**
	 * 判断Obj是否为null
	 * @param obj
	 * @return
	 */
	public static boolean isNotEmpty(Object obj){
		if(obj!=null){
			if(obj instanceof String){
				if(!"".equals(((String) obj).trim())){
					return Boolean.TRUE;
				}
			}
			if(obj instanceof List){
				return ((List)obj).size()>0;
			}
			if(obj instanceof Map){
				return !((Map)obj).isEmpty();
			}
			return true;
		}else{
			return false;
		}
	}
	
	public static boolean isNotEmptyIntStr(Object value){
		if (value instanceof String) {
			if(isNotEmpty(value)){
				return true;
			}
		}else if(value instanceof Integer){
			return true;
		}
		return false;
	}
	public static boolean isNotEmptyObj(Object value){
		if(value instanceof String || value instanceof Integer){
			return isNotEmptyIntStr(value);
		}else{
			return isNotEmpty(value);
		}
	}
	public static boolean isNotEmptyForList(List lst){
		if(lst!=null&&lst.size()>0){
			return true;
		}
		return false;
	}
	/**
	 * 判断是否有效的文件路径，文件路径不能//或\开头
	 * @param path
	 * @return true 路径有效
	 */
	public static String getFormatPath(String path){
		if(isNotEmpty(path)){
			if(path.startsWith("/")){
				return path.substring(1);
			}else if(path.startsWith("\\")){
				return path.substring(2);
			}
		}
		return path;
	}
	public static String getLastYear(){
		return ""+(Calendar.getInstance().get(1)-1);
	}
	public static void main(String[] arg) throws ParseException{
		/*
		 GdApplyInitInfo applyInitInfo=new GdApplyInitInfo();
		 GdSydwInfo sydwInfo=new GdSydwInfo();
		 final String fieldCopys[]= new String[]{"sydwId","jbdwId","ownerid","groupId","districtCode"};
		 sydwInfo.setSydwId(new Long(2222));
		 sydwInfo.setJbdwId(121l);
		 sydwInfo.setGroupId(12l);
		 sydwInfo.setOwnerid(null);
		 sydwInfo.setDistrictCode("aaaaa");
		 sydwInfo.setDistCode("dddd");
		 applyInitInfo=(GdApplyInitInfo)Utility.copyObjectByProperties(sydwInfo, applyInitInfo, fieldCopys,fieldCopys);
		 if(isEqualsByPoperties(sydwInfo, applyInitInfo, new String[]{"sydwId"})){
			 System.out.println("okokook");
		 }
		 System.out.println(applyInitInfo.getSydwId()+" ownerid: \t"+applyInitInfo.getOwnerid()+"distCode=\t"+applyInitInfo.getDistrictCode());
		 
		List lsList=new ArrayList();
		lsList.add(1);
		Map map =new HashMap();
		map.put("ddd", 9);
		System.out.println(isNotEmpty(map));
		*/
		List<String>lst =  getStrYearLst();
		for(String ss:lst)System.out.println(ss);
	}
	public static String getStrYear(Date dateTime) {
		String date = "";
		try{
			DateFormat fmt = new SimpleDateFormat("yyyy");
			date=fmt.format(dateTime);
		}catch(Exception e){
			return "";
		}
		if(date==null){
			date="";
		}
		return date;
	}

	/**
	 * 获得sqlDate否则返回当前时间
	 * @param utilDate
	 * @return
	 */
	public static java.sql.Date getSqlDate(java.util.Date utilDate){
		java.sql.Date sqlDate=null; 
		if(utilDate!=null){
			sqlDate = new java.sql.Date(utilDate.getTime());
		}else{
			sqlDate = new java.sql.Date(new java.util.Date().getTime()); 
		}
		return sqlDate;
	}
	/**
	 * 获得sqlDate否则返回null
	 * @param utilDate
	 * @return 返回utilDate的sql格式的时间，utilDate is null则返回null
	 */
	public static java.sql.Date getisNullSqlDate(java.util.Date utilDate){
		java.sql.Date sqlDate=null; 
		if(utilDate!=null){
			sqlDate = new java.sql.Date(utilDate.getTime());
		}
		return sqlDate;
	}
	/**
	 * 判断时间是否为null
	 * @param time 
	 * @return 不为空返回true
	 */
	public static boolean isNotEmpty(Date time){
		if(time!=null){
			return true;
		}else{
			return false;
		}
	}
	public static Integer parseInt(String obj){
		if(isNotEmptyIntStr(obj)){
			return Integer.parseInt(obj);
		}
		return 0;
	}
	/**
	 * 2个Integer对象相加
	 * @param val1
	 * @param val2
	 * @return
	 */
	public static int plus(Integer val1,Integer val2){
		int v1=0;
		int v2=0;
		if(val1!=null){
			v1=val1;
		}
		if(val2!=null){
			v2=val2;
		}
		return v1+v2;
	}
	/**
	 * 将数据格式化为数据类型
	 * @param getName 必须按照entity格式书写，否则错误。
	 * @return 返回 get_Name
	 */
	public static String NativeSql(String getName){
		if(getName==null){
			return "";
		}
		int hs=0;
		for (int i = 0; i < getName.length(); i++) {
			hs=getName.charAt(i);
			if(hs>='A'&&hs<='Z'){
				String tmp1=getName.substring(0,i);
				String tmp2=getName.substring(i);
				getName=tmp1+"_"+tmp2;
				i++;
			}
		}
		return getName;
	}
	
	/**
	 * 比较日期yyyy-MM-dd d1要小于等于d2才返回true.例如:2008-1-1<=2009-1-1 return true;
	 * @param d1 is null {return false}
	 * @param d2 is null {return false}
	 * @return d1<=d2 {return true} else{ return false}
	 */
	public static boolean compareData(Date d1,Date d2){
		
		if(Utility.isNotEmpty(d1)&&Utility.isNotEmpty(d2)){
			
			Calendar c1= Calendar.getInstance();
			Calendar c2= Calendar.getInstance();
			
			c1.setTime(d1);
			c2.setTime(d2);
			
			if(c1.get(Calendar.YEAR)<c2.get(Calendar.YEAR)){
				return true;
			}else if(c1.get(Calendar.YEAR)==c2.get(Calendar.YEAR)){
				if(c1.get(Calendar.MONTH)<c2.get(Calendar.MONTH)){
					return true;
				}else if(c1.get(Calendar.MONTH)==c2.get(Calendar.MONTH)){
					if(c1.get(Calendar.DATE)<=c2.get(Calendar.DATE)){
						return true;
					}
				}
			}
		}
		return false;
	}
	/**
	 * 验证时间在数据库中是否有效 时间格式yyyy-MM-dd
	 * 判断依据时间必须在这段范围 1753 年 1 月 1 日到 9999 年 12 月 31 日
	 * @param date 时间为null这不判断，返回true有效
	 * @return
	 */
	public static boolean validateSqlDate(Date date){
		if(date!=null){
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
			try {
				Date frontDate = dateFormat.parse("1753-1-1");
				Date lastDate = dateFormat.parse("9999-12-31");
				
				if((lastDate.after(date)&&frontDate.before(date))
						||lastDate.equals(date)||lastDate.equals(date)){
					return true;
				}else{
					return false;
				}
			} catch (ParseException e) {
				e.printStackTrace();
				return true;
			}
		}
		return true;
	}
	
	/**
	 * 传入一个字符串,去掉空格,以及一些非法字符.
	 * (例如通过xls获取数据的时候,有一些非法字符也是显示的空格,看不见)
	 * @param string
	 * @return
	 */
	public static String getFilterString(String string){
		if(string == null || string.equals("")){
			return string;
		}
		/* 去掉空格和去掉非法字符(看不到的字符,实际上不是空格) */
		char c1 = 160;
		string = string.replaceAll(c1+"", "");
		string = string.trim();
		return string;
	}
	/**
	 * sql拼凑特殊字符处理
	 * @param str
	 * @return
	 */
	public static String getSqlSpecialChar(String str){
		if(str==null){
			return str="";
		}
		return str.replaceAll("'", "''");
	}
	public static boolean isNotEmptyForList(Set lst){
		if(lst!=null&&lst.size()>0){
			return true;
		}
		return false;
	}
	/**
	 * 返回一个不为负数的数
	 * @param value
	 * @return
	 */
	public static Integer getIntNotMinus(Integer value){
		int returnValue=getIntNotEmpty(value);
		if(returnValue<0){
			returnValue=0;
		}
		return returnValue;
	}
	public static Double getDoubleNotEmpty(Double value){
		if(value!=null){
			return value;
		}
		return 0.00;
	}
	public static Integer getIntNotEmpty(Integer value){
		if(!isNotEmptyIntStr(value)){
			return 0;
		}
		return value;
	}
	public static Integer getIntNotEmpty(String value){
		if(!isNotEmptyIntStr(value)){
			return 0;
		}
		return Integer.parseInt(value);
	}
	public static Integer getIntNotEmpty(Object value){
		if(!isNotEmpty(value)&&!isNotEmptyIntStr(value)){
			return 0;
		}
		return Integer.parseInt(value.toString());
	}
	public static Object[] getIntNotEmpty(Object[] value){
		if(Utility.isNotEmpty(value)){
			for (int i = 0; i < value.length; i++) {
				value[i]=getIntNotEmpty(value[i]);
			}
		}
		return value;
	}
	public static Long getLongNotEmpty(Long value){
		if(!isNotEmpty(value)){
			return 0L;
		}
		return value;
	}
	/**
	 * 获得指定长度的数组
	 * @param value
	 * @param len 指定长度 默认 0(当value为null时使用)
	 * @return
	 */
	public static Object[] getIntNotEmpty(Object[] value,Integer len){
		if(!Utility.isNotEmpty(value)){
			value=new Object[Utility.getIntNotEmpty(len)];
		}
		return getIntNotEmpty(value);
	}
	public static String getStrNotEmpty(String value){
		if(!isNotEmptyIntStr(value)){
			return "";
		}
		return value.trim();
	}
	public static Integer[] getIntNotEmpty(Object[] value,Integer[] toValue){
		if(Utility.isNotEmpty(value)){
			for (int i = 0; i < value.length; i++) {
				toValue[i]=getIntNotEmpty(value[i]);
			}
		}
		return toValue;
	}
	/**
	 * str.split(";;");
	 * @param str str.split(";;");
	 * @return
	 */
	public static String[] splitForString(String str){
		String tmp="";
		if(isNotEmpty(str)){
			if(str.contains(";;")){
				int count=0;
				String[] st=str.split(";;");
				for (int i = 0; i < st.length; i++) {
					if(isNotEmptyIntStr(st[i].trim())){
						if(count!=0){
							tmp+=";;";
						}
						tmp+=st[i].trim();
						count++;
					}
				}
				if(tmp.contains(";;")){
					return tmp.split(";;");
				}else if(isNotEmpty(tmp)){
					return new String[]{tmp.trim()};	
				}
			}else{
				return new String[]{str.trim()};
			}
		}
		return null;
	}
	/**
	 * str
	 * @param str str是一个已“,”分隔符的字符串
	 * @return
	 */
	public static List<Integer> getIntLstForStr(String str){
		List<Integer> ids = new ArrayList<Integer>(0);
		if(str!=null&&!"".equals(str)){
			String[] st=str.split(",");
			for (int i = 0; i < st.length; i++) {
				if(Utility.isNotEmpty(st[i])){
					try{
						ids.add(Integer.parseInt(st[i]));
					}catch(NumberFormatException nex){
						nex.printStackTrace();
					}
				}
			}
		}
		return ids;
	}
	public static List<Object> getObjLstForStr(String str){
		List<Object> ids = new ArrayList<Object>(0);
		if(str!=null&&!"".equals(str)){
			String[] st=str.split(",");
			for (int i = 0; i < st.length; i++) {
				if(Utility.isNotEmpty(st[i])){
					try{
						ids.add(st[i]);
					}catch(NumberFormatException nex){
						nex.printStackTrace();
					}
				}
			}
		}
		return ids;
	}
	public static List<Long> convertLongList(List<Object> lst){
		List<Long> longLst = new ArrayList<Long>();
		if(Utility.isNotEmptyForList(lst)){
			Long tmp=null;
			for (Object id : lst) {
				if(Utility.isNotEmpty(id.toString())){
					tmp=Long.parseLong(id.toString().trim());
					longLst.add(tmp);
				}
			}
		}
		return longLst;
	}
	/**
	 * 检查出是否有0数据
	 * @param lst
	 * @return 有0 返回true
	 */
	public static boolean eachZero(List<Long> lst){
		if(Utility.isNotEmptyForList(lst)){
			for (Long id : lst) {
				if(id==0){
					return true;
				}
			}
		}
		return false;
	}
	/**
	 * 获得准确的拼凑语句
	 * @param str
	 * @return
	 */
	public static String getIntStrForStr(String str){
		return getIntStrForStr(getIntLstForStr(str));
	}
	/**
	 * 获得准确的拼凑语句
	 * @param str
	 * @return
	 */
	public static String getIntStrForStr(List<Integer> ids){
		if(Utility.isNotEmptyForList(ids)){
			StringBuffer st = new StringBuffer();
			for (int i = 0; i < ids.size(); i++) {
				if(i>0){
					st.append(",");
				}
				st.append(ids.get(i));
			}
			return st.toString();
		}
		return null;
	}
	/**
	 * 获得准确的拼凑语句
	 * @param str
	 * @return
	 */
	public static String getStrForObjArray(Object[] obj){
		if(Utility.isNotEmpty(obj)){
			StringBuffer st = new StringBuffer();
			for (int i = 0; i < obj.length; i++) {
				if(i>0){
					st.append("、");
				}
				st.append(obj[i]);
			}
			return st.toString();
		}
		return null;
	}
	/**
	 * 创建文件目录
	 * @param path
	 * @return
	 */
	public static String mkdirs(String path){
		File file = new File(path);
		if(!file.isDirectory()){
			file.mkdirs();
		}
		return path;
	}
	/**
	 * 判断文件是否存在
	 * @param path
	 * @return ture文件存在
	 */
	public static boolean fileExists(String path){
		File file = new File(path);
		return file.exists();
	}
	/**
	 * 判读是否特殊用编
	 * @param specialAuth 1表示特殊用编
	 * @return true 为特殊用编
	 */
	public static boolean isSpecialAuth(Integer specialAuth){
		if(Utility.isNotEmpty(specialAuth)&&specialAuth==1){
			return true;
		}
		return false;
	}
	/**
	 * 为不为空的语句 添加 and
	 * @param sql
	 * @return Utility.isNotEmpty(sql) 为 true 返回添加and的语句 否则返回 sql 
	 */
	public static String addAndForSql(String sql){
		if(Utility.isNotEmpty(sql)){
			return " and "+sql;
		}
		return sql;
	}
	/**
	 * 为不为空的语句 添加 or
	 * @param sql
	 * @return Utility.isNotEmpty(sql) 为 true 返回添加or的语句 否则返回 sql 
	 */
	public static String addOrForSql(String sql){
		if(Utility.isNotEmpty(sql)){
			return " or "+sql;
		}
		return sql;
	}
	/**
	 * 为指定日期 添加年份
	 * @param time 日期 is null 获得当前日期
	 * @param year 年份
	 * @return 返回的日期 没有时间
	 */
	public static Date addYearsDate(Date time,Integer year){
		return addAllDate(time, year, null, null);
	}
	/**
	 * 指定月份添加
	 * @param time
	 * @param month
	 * @return
	 */
	public static Date addMonthsDate(Date time,Integer month){
		return addAllDate(time, null, month, null);
	}
	
	/**
	 * 全部格式添加 年份 月份 日期 
	 * @param time
	 * @param year
	 * @param month
	 * @param day
	 * @return
	 */
	public static Date addAllDate(Date time,Integer year,Integer month,Integer day){
		Calendar cd = Calendar.getInstance();
		if(Utility.isNotEmpty(time)){
			cd.setTime(time);
		}
		if(year!=null){
			cd.add(Calendar.YEAR,Utility.getIntNotEmpty(year));
		}
		if(month!=null){
			cd.add(Calendar.MONTH,Utility.getIntNotEmpty(month));
		}
		if(day!=null){
			cd.add(Calendar.DATE, Utility.getIntNotEmpty(day));
		}
		return getDateFStrings(getCurrentDate(cd.getTime()));
	}
	/**
	 * 将from数据添加到to数据中，返回最大object数组
	 * @param from 
	 * @param to
	 * @return
	 */
	public static Object[] addToArrays(Object[] from,Object[] to){
		if(!Utility.isNotEmpty(to)){
			to=new Object[0];
		}
		if(Utility.isNotEmpty(from)){
			Object[] tmp = new Object[to.length+from.length];
			int i=0;
			for (Object t : to) {
				tmp[i]=t;
				i++;
			}
			for (Object t : from) {
				tmp[i]=t;
				i++;
			}
			return tmp;
		}else{
			return to;
		}
	}
	/**
	 * 为不为空的对象添加括号
	 * @param str
	 * @return  abc return (abc)
	 */
	public static String addbracket(String str){
		if(Utility.isNotEmpty(str)){
			return "("+str+")";
		}
		return "";
	}
	/**
	 * 比较Name[0]
	 * @param lst
	 * @param obj
	 * @return 返回查询到的数据
	 */
	public static Object[] getObjValue(List lst,Object obj){
		for(int i=0;i<lst.size();i++){
			Object[] o=(Object[])lst.get(i);
			if(o[0].equals(obj)){
				return o;
			}
		}
		return null;
	}
	/**
	 * 比较Name[0]
	 * @param lst
	 * @param obj
	 * @return 返回查询到的数据
	 */
	public static Object[] getIndexValue(List lst,Object obj){
		for(int i=0;i<lst.size();i++){
			Object[] o=(Object[])lst.get(i);
			if((o[0].toString().indexOf(obj.toString()))==0){
				return o;
			}
		}
		return null;
	}
	
	/**
	 * 通过数组长度和初始值  返回一个新的数组
	 * @param len 数组长度
	 * @param value 初始值
	 * @return
	 */
	public static Integer[] setArrayInitialValue(Integer len,Integer value) {
		if(value==null){
			value=0;
		}
		Integer[] intArray = new Integer[]{};
		if (isNotEmpty(len)) {
			intArray = new Integer[len];
		}
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = value;
		}
		return intArray;
	}
	
	/**
	 * 通过数组长度和初始值  返回一个新的数组
	 * @param len 数组长度
	 * @param value 初始值
	 * @return
	 */
	public static String[] setArrayInitialValue(Integer len,String value) {
		if(value==null){
			value="";
		}
		String[] strArray = new String[]{};
		if (isNotEmpty(len)) {
			strArray = new String[len];
		}
		for (int i = 0; i < strArray.length; i++) {
			strArray[i] = value;
		}
		return strArray;
	}
	
	/**
	 * 通过数组长度和初始值  返回一个新的数组
	 * @param len 数组长度
	 * @param value 初始值
	 * @return
	 */
	public static Boolean[] setArrayInitialValue(Integer len,Boolean value) {
		if(value==null){
			value=false;
		}
		Boolean[] strArray = new Boolean[]{};
		if (isNotEmpty(len)) {
			strArray = new Boolean[len];
		}
		for (int i = 0; i < strArray.length; i++) {
			strArray[i] = value;
		}
		return strArray;
	}
	/**
	 * 通过sp 得到value指定数据 sp[i]>=0
	 * @param rtv rtv.split(",")
	 * @param value
	 * @return
	 */
	public static String[] getStringValue(String rtv,String[] value){
		if(Utility.isNotEmpty(rtv)){
			String[] sp =rtv.split(",");
			List<String> lst = new ArrayList<String>();
			if(sp.length>0){
				try{
	    			for (int i = 0; i < sp.length; i++) {
	        			try{
	    					if(Integer.parseInt(sp[i])>=0){
	    						lst.add(value[i]);
	    					}
	    				}catch(Exception e){
	    					e.printStackTrace();
	    				}
	    			}
	    		}catch(Exception e){
	    			e.printStackTrace();
	    		}
			}
			return lst.toArray(new String[]{});
		}
		return new String[0];
	}
	//阿拉伯数字转中文小写
	public static String toConvtZH(int intInput)
    {
    	String sd = toCH(intInput);
        String sd2 = sd;
        if ((intInput+"").length() > 2 && ((intInput / 10 % 10) == 1))
        {
            //sd2 = sd.insert(sd.lastIndexOf('十'), "一");
            sd2.lastIndexOf("十一", sd.lastIndexOf('十'));
        }
        return sd2;
    }
	public static String toCH(int intInput)
    {
        String si = intInput+"";
        String sd = "";
        if (si.length() == 1)     //个
        {
            sd += getCH(intInput);
            return sd;
        }
        else if (si.length() == 2)//十
        {
            if (si.substring(0, 1).equals("1"))
                sd += "十";
            else
                sd += (getCH(intInput / 10) + "十");
            sd += toCH(intInput % 10);
        }
        else if (si.length() == 3)//百
        {
            sd += (getCH(intInput / 100) + "百"); 
            if (((intInput % 100)+"").length() < 2)
                sd += "零";
            sd += toCH(intInput % 100);
        }
        else if (si.length() == 4)//千
        {
            sd += (getCH(intInput / 1000) + "千");
            if (((intInput % 1000)+"").length() < 3)
                sd += "零";
            sd += toCH(intInput % 1000);
        }
        else if (si.length() == 5)//萬
        {
            sd += (getCH(intInput / 10000) + "万");
            if (((intInput % 10000)+"").length() < 4)
                sd += "零";
            sd += toCH(intInput % 10000);
        }

        return sd;
    }

    private static String getCH(int input)
    {
        String sd = "";
        switch (input)
        {
            case 1:
                sd = "一";
                break;
            case 2:
                sd = "二";
                break;
            case 3:
                sd = "三";
                break;
            case 4:
                sd = "四";
                break;
            case 5:
                sd = "五";
                break;
            case 6:
                sd = "六";
                break;
            case 7:
                sd = "七";
                break;
            case 8:
                sd = "八";
                break;
            case 9:
                sd = "九";
                break;
            default:
                break;
        }
        return sd;
    }
	public static String genRandomNum(int pwd_len) {
		// 35是因为数组是从0开始的，26个字母+10个数字
		final int maxNum = 36;
		int i; // 生成的随机数
		int count = 0; // 生成的密码的长度
		char[] str = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
				'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
				'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

		StringBuffer pwd = new StringBuffer("");
		Random r = new Random();
		while (count < pwd_len) {
			// 生成随机数，取绝对值，防止生成负数，

			i = Math.abs(r.nextInt(maxNum)); // 生成的数最大为36-1

			if (i >= 0 && i < str.length) {
				pwd.append(str[i]);
				count++;
			}
		}

		return pwd.toString();
	}
	/**
	 * 获得拼凑语句
	 * @param str
	 * @return
	 */
	public static String getStrForList(List lst){
		if(Utility.isNotEmptyForList(lst)){
			StringBuffer st = new StringBuffer();
			for (int i = 0; i < lst.size(); i++) {
				if(i>0){
					st.append(",");
				}
				Object str=lst.get(i);
				if(str instanceof Integer){
					st.append(str);
				}else{
					st.append("'"+str+"'");
				}
			}
			return st.toString();
		}
		return null;
	}
	/**
	 * 获得拼凑语句
	 * @param str
	 * @return
	 */
	public static String getStrForArrays(Object[] obj){
		if(Utility.isNotEmpty(obj)){
			StringBuffer st = new StringBuffer();
			for (int i = 0; i < obj.length; i++) {
				if(i>0){
					st.append(",");
				}
				Object str=obj[i];
				if(str instanceof Integer){
					st.append(str);
				}else{
					st.append("'"+str+"'");
				}
			}
			return st.toString();
		}
		return null;
	}

    public static String[] getStrFields(Class o,String[] unGetStrLst){
        
    	java.lang.reflect.Field[] fields = o.getDeclaredFields();
    	int leng = fields.length;
    	StringBuffer sbBuffer = new StringBuffer();
		for(int i=0;i<fields.length;i++){
			if(i!=leng-1)
				sbBuffer.append(fields[i].getName()).append(",");
			else 
				sbBuffer.append(fields[i].getName());
		}
		String rs = sbBuffer.toString();
		if(null != unGetStrLst){
			for(String s:unGetStrLst){
				rs = rs.replaceAll((s+",") , "");
			}	
		}
    	return rs.split(",");
    }

 
	/**
	 * 得到当前的时间，格式(yyMMddHHmmss)年月日时分秒，年取后两位，如:121203184920
	 * @return
	 */
	public static String getNowTime(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
		return sdf.format(new Date());
	}

	/**
	 * 格式化字符串，在字符串右边加0，返回length长度的字符串
	 * @param str 要格式化的字符串
	 * @param length 要返回字符串的长度
	 * @return
	 */
	public static String getStringByLength(String str,int length){
		String tmp = "";
		for (int i = 0; i < length; i++) {
			tmp += "0";
		}
		if (isNotEmpty(str)) {
			str += tmp;
		} else {
			str = tmp;
		}
		return str;
	}
	
	public static List<String> getStrYearLst(){
		List<String> lst = new ArrayList<String>();
		String year = getLastYear();
		
		Integer yearInt = Integer.valueOf(year);
		for(int i=0;i<5;i++){
			//yearInt
			lst.add(String.valueOf(yearInt--));
		}
		return lst;
	}
	/**
	 * 生成对象修改日志
	 * @author Jan 7, 2013 xiaofei0620@gmail.com
	 * @param before 变化之前的对象
	 * @param after 变化之后的对象
	 * @param mapPropTitle 属性与名称之间的对
	 * @param separtor1 不同属性之间的分隔符号
	 * @param separtor2 属性与属性值之间的分隔符号
	 * @return 
	 */
	public static String[] getAlterLog(Object before,Object after,Map<String,String> mapPropTitle,String separtor1,String separtor2){
		if(before==null||after==null){
			return null;
		}
		if(mapPropTitle==null){
			return null;
		}
		if(!isNotEmpty(separtor1)){
			separtor1="&";
		}
		if(!isNotEmpty(separtor2)){
			separtor2="#";
		}
		StringBuffer logAfterStr=new StringBuffer();
		StringBuffer logBeforeStr=new StringBuffer();
		for (String colName : mapPropTitle.keySet()) {
			Object a=getFieldValue(after,colName);
			Object b=getFieldValue(before,colName);
			if(!equals(a, b)){
			   if(logAfterStr.length()>0){
				   logAfterStr.append(separtor1);
			   }
			   logAfterStr.append(mapPropTitle.get(colName)+separtor2).append(a);
			   
			   if(logBeforeStr.length()>0){
				   logBeforeStr.append(separtor1);
			   }
			   logBeforeStr.append(mapPropTitle.get(colName)+separtor2).append(b);
		   }
		}
		return new String[]{logBeforeStr.toString(),logAfterStr.toString()};
	}
	/**
	 * @author Jan 30, 2013 xiaofei0620@gmail.com
	 * @param ownerid
	 * @return
	 */
	public static String removelastZero(String ownerid){
		if(ownerid==null||ownerid.trim().equals("")){
			return ownerid;
		}
		ownerid=ownerid.trim();
		int length=ownerid.length();
		if(length>=1&&ownerid.substring(length-1,length).equals("0")){
			ownerid=ownerid.substring(0,length-1);
		}else{
			return ownerid;
		}
		return removelastZero(ownerid);
	}
	public static List<String> getStrLstForStr(String str){
		List<String> ids = new ArrayList<String>(0);
		if(str!=null&&!"".equals(str)){
			String[] st=str.split(",");
			for (int i = 0; i < st.length; i++) {
				if(Utility.isNotEmpty(st[i])){
					try{
						ids.add(st[i]);
					}catch(NumberFormatException nex){
						nex.printStackTrace();
					}
				}
			}
		}
		return ids;
	}
}
